﻿using HelloMinasan.Web.Song.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml;

namespace HelloMinasan.Web.Song.Controllers
{
    //public class RssResult : ActionResult
    //{
    //    private readonly SyndicationFeed _feed;
    //    public RssResult(SyndicationFeed feed)
    //    {
    //        _feed = feed;
    //    }


    //    public override void ExecuteResult(ControllerContext context)
    //    {
    //        context.HttpContext.Response.ContentType = "application/ress+xml";
    //        var formatter = new Rss20FeedFormatter(_feed);
    //        using (var writer = XmlWriter.Create(context.HttpContext.Response.Output))
    //        {
    //            formatter.WriteTo(writer);
    //        }
    //    }
    //}

    //public class RssController : Controller
    //{
    //    // GET: /Rss/
    //    [HttpGet]
    //    public ActionResult Rss()
    //    {
    //        string url = ConstantsHelper.GetBaseUrl(new UrlHelper(Request.RequestContext));
    //        var songList = new SongRepository().GetAllSongs();
    //        var syndication = songList.Select(model => getRssItem(url, model));
    //        var feed = new SyndicationFeed("Songs#", "Song from website#", Request.Url, syndication.ToList());
    //        return new RssResult(feed);
    //    }

    //    private SyndicationItem getRssItem(string baseUrl, Song model)
    //    {
    //        var url = baseUrl + Url.Action("Songs", "Song", new { id = model.SongId });
    //        return new SyndicationItem(model.SongName, string.Empty, new Uri(url), model.SongId.ToString(), new DateTimeOffset(model.PostedDate));
    //    }

    //}
}
